<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 输入一个链表， 按链表从尾到头的顺序返回一个ArrayList。
        function Node(value) {
            this.val = value;
            this.next = null
            this.pre = null
        }

        let a = new Node(67);
        let b = new Node(0);
        let c = new Node(24);
        let d = new Node(58);

        a.next = b;
        a.pre = null;
        b.next = c;
        b.pre = a;
        c.next = d;
        c.pre = b;
        d.next = null;
        d.pre = c

        function printListFromTailToHead(head) {
            let arr = [];
            while (head != null) {
                arr.unshift(head.val);
                head = head.next;
            }
            return arr;
        }

        console.log(printListFromTailToHead(a))
    </script>
</body>

</html>